package com.example.yk_lx.addFriend;

import androidx.appcompat.app.AppCompatActivity;
import androidx.lifecycle.Observer;

import android.os.Bundle;
import android.view.View;

import com.alibaba.android.arouter.facade.annotation.Route;
import com.blankj.utilcode.util.ToastUtils;
import com.example.yk_lx.R;
import com.example.yk_lx.baseMVVM.BaseActivity;
import com.example.yk_lx.databinding.ActivityAddfriBinding;

@Route(path = "/app/AddfriActivity")
public class AddfriActivity extends BaseActivity<ActivityAddfriBinding,AddFriViewModel> {


    @Override
    protected int bindLayout() {
        return R.layout.activity_addfri;
    }

    @Override
    protected void initView() {
        dataBinding.send.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                viewModel.addFri(dataBinding.tvUser.getText().toString(),dataBinding.tvReason.getText().toString());
            }
        });
    }

    @Override
    protected void initData() {
        viewModel.success.observe(this, new Observer<String>() {
            @Override
            public void onChanged(String s) {
                ToastUtils.showLong(s);
                finish();
            }
        });
        viewModel.fail.observe(this, new Observer<String>() {
            @Override
            public void onChanged(String s) {
                ToastUtils.showLong(s);
            }
        });
    }

    @Override
    protected Class<AddFriViewModel> getViewModel() {
        return AddFriViewModel.class;
    }
}